package com.ruoyi.web.controller.teacher;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.SysCollege;
import com.ruoyi.teacher.service.ISysCollegeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * sysCollegeController
 * @author ruoyi
 * @date 2022-01-13
 */
@Controller
@RequestMapping("/teacher/college")
public class SysCollegeController extends BaseController
{
    private String prefix = "teacher/college";

    @Autowired
    private ISysCollegeService sysCollegeService;

    @RequiresPermissions("teacher:college:view")
    @GetMapping()
    public String college()
    {
        return prefix + "/college";
    }

    /**
     * 查询sysCollege列表
     */
    @RequiresPermissions("teacher:college:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysCollege sysCollege)
    {
        startPage();
        List<SysCollege> list = sysCollegeService.selectSysCollegeList(sysCollege);
        return getDataTable(list);
    }

  /*  *//**
     * 导出sysCollege列表
     *//*
    @RequiresPermissions("teacher:college:export")
    @Log(title = "sysCollege", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysCollege sysCollege)
    {
        List<SysCollege> list = sysCollegeService.selectSysCollegeList(sysCollege);
        ExcelUtil<SysCollege> util = new ExcelUtil<SysCollege>(SysCollege.class);
        return util.exportExcel(list, "学生数据");
    }
*/
   /* @RequiresPermissions("teacher:college:view")
    @GetMapping("/importTemplate")
    @ResponseBody
    public AjaxResult importTemplate()
    {
        ExcelUtil<SysCollege> util = new ExcelUtil<SysCollege>(SysCollege.class);
        return util.importTemplateExcel("学生数据");
    }

    @Log(title = "学生管理", businessType = BusinessType.IMPORT)
    @RequiresPermissions("teacher:college:import")
    @PostMapping("/importData")
    @ResponseBody
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<SysCollege> util = new ExcelUtil<SysCollege>(SysCollege.class);
        List<SysCollege> userList = util.importExcel(file.getInputStream());
        String message = sysCollegeService.importStudent(userList, updateSupport, getLoginName());
        return AjaxResult.success(message);
    }*/

    /**
     * 新增sysCollege
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存sysCollege
     */
    @RequiresPermissions("teacher:college:add")
    @Log(title = "sysCollege", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysCollege sysCollege)
    {
        sysCollege.setCreateBy(getLoginName());
        return toAjax(sysCollegeService.insertSysCollege(sysCollege));
    }

    /**
     * 修改sysCollege
     */
    @RequiresPermissions("teacher:college:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysCollege sysCollege = sysCollegeService.selectSysCollegeById(id);
        mmap.put("sysCollege", sysCollege);
        return prefix + "/edit";
    }

    /**
     * 修改保存sysCollege
     */
    @RequiresPermissions("teacher:college:edit")
    @Log(title = "sysCollege", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysCollege sysCollege)
    {
        sysCollege.setUpdateBy(getLoginName());
        return toAjax(sysCollegeService.updateSysCollege(sysCollege));
    }

    /**
     * 删除sysCollege
     */
    @RequiresPermissions("teacher:college:remove")
    @Log(title = "sysCollege", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysCollegeService.deleteSysCollegeByIds(ids));
    }


/*
    */
/**
     * 校验用户名
     *//*

    @PostMapping("/checkCardUnique")
    @ResponseBody
    public String checkCardUnique(SysCollege sysCollege)
    {
        return sysCollegeService.checkCardUnique(sysCollege.getCard());
    }

    @PostMapping("/checkCollegeIdUnique")
    @ResponseBody
    public String checkCollegeIdUnique(SysCollege sysCollege)
    {
        return sysCollegeService.checkCollegeIdUnique(sysCollege.getCollegeId());
    }
*/


}
